package cumeo89.chii.client.entry.renderer;

import static cumeo89.chii.client.entry.Constants.*;

import com.google.gwt.xml.client.Attr;
import com.google.gwt.xml.client.Node;

import cumeo89.chii.client.entry.Renderer;

public class PosRenderer extends HeaderListRenderer {

	public PosRenderer() {
		super();
		getWidget().setStyleName("pos");
	}

	@Override
	public void addRenderer(Renderer child) {
		Node node = child.getRenderedNode();
		if (node.getNodeType() == Node.ATTRIBUTE_NODE
				&& A_POS_SPELL.equals(((Attr) node).getName())) {
			getChildContainer().insert(child.getWidget(), 0);
		} else {
			super.addRenderer(child);
		}
	}

	@Override
	public void removeRenderer(Renderer child) {
		Node node = child.getRenderedNode();
		if (node.getNodeType() == Node.ATTRIBUTE_NODE
				&& A_POS_SPELL.equals(((Attr) node).getName())) {
			child.getWidget().removeFromParent();
		} else {
			super.removeRenderer(child);
		}
	}

}
